const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name:'',
    uuid:'',
    applyName:'',
    applyTel:'',
    applyContens:''
  },
  applyName:function (e) {
    this.setData({
        applyName: e.detail.value
    });
  },
  applyTel:function (e) {
    this.setData({
        applyTel: e.detail.value
    });
  },  
  applyContens:function (e) {
    this.setData({
        applyContens: e.detail.value
    });
  },

  bmSubmit:function () {
    if (this.data.applyName.length < 1) {
      wx.showModal({
        title: "Feijiu网提示您",
        content: "请输入您的真实姓名,方便我们联系您",
        showCancel: false,
        confirmText: "确定"
      })
      return false
    }
    if (this.data.applyTel.length < 1) {
      wx.showModal({
        title: "Feijiu网提示您",
        content: "请输入您的正确手机号,方便我们联系您",
        showCancel: false,
        confirmText: "确定"
      })
      return false
    }else{
      if (!(/^1[3456789]\d{9}$/.test(this.data.applyTel))) {
        wx.showModal({
          title: "Feijiu网提示您",
          content: "请输入您的正确手机号,方便我们联系您",
          showCancel: false,
          confirmText: "确定"
        })
        return false
      }
    }
    if (app.checkFjLogin()) {
      var FjLoginLog = wx.getStorageSync('FjLoginLog'); 
      var loginUID = FjLoginLog.UID;
    }else{
      var loginUID = 0;
    }
    var that = this;
    var api_input = {
      uuid:this.data.uuid,
      name:this.data.name,
      applyName:this.data.applyName,
      applyTel:this.data.applyTel,
      applyContens:this.data.applyContens,
      loginUID:loginUID
    }

// uuid：公告信息UUID，name：公告信息标题，loginUID：登录用户编号，applyName：姓名，applyTel：联系电话，applyContens：补充说明

    app.getDaoPostJp('api/BulletinService/bulletin_Add_Apply',api_input,function (r) {
      if (r.code == 200) {       
        var tishi = '您的报名信息提交成功,稍后我们的客服人员会和您联系';      
        wx.showModal({
          title: "Feijiu网提示您",
          content: tishi,
          showCancel: false,
          confirmText: "确定",
          success: (res) => {
            wx.navigateBack() 
          },          
        })
      }else{
        app.tishi(r.message);
      }      
    })
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {    
    this.setData({
      name:options.name,
      uuid:options.uuid      
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})